package com.qyhl.webtv.module_microvideo.shortvideo.classic;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.microvideo.ClassicHomeBean;
import com.qyhl.webtv.commonlib.entity.microvideo.ShortVideoBean;
import com.qyhl.webtv.module_microvideo.common.VideoUrl;

import java.util.List;

public class ClassicHomeModel implements ClassicHomeContract.ClassicHomeModel {
    private ClassicHomePresenter mPresenter;

    public ClassicHomeModel(ClassicHomePresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getHomeData() {
        EasyHttp.get(VideoUrl.GET_CLASSIC_HOME)
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .execute(new SimpleCallBack<ClassicHomeBean>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setError("暂无任何内容！");
                        } else {
                            mPresenter.setError("请求出错，请重新获取！");
                        }
                    }

                    @Override
                    public void onSuccess(ClassicHomeBean classicHomeBean) {
                        mPresenter.setHomeData(classicHomeBean);
                    }
                });
    }

}
